package com.bys.controller;

import com.bys.po.Tsn;
import com.bys.service.TsnService;
import com.bys.util.PageResult;
import com.bys.util.R;
import com.bys.vo.TsnVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
@RestController
@RequestMapping("/tsn")
@CrossOrigin
public class TsnController {
    @Autowired
    private TsnService tbService;
    @GetMapping("/list")
    public List<Tsn> list(){

        return tbService.findAll();}
    @GetMapping("/findByPage")
    public PageResult<Tsn> findByPage(@RequestParam("page") Integer page, @RequestParam("pageSize") Integer pageSize){
        return tbService.findByPage(page,pageSize);
    }
    @PostMapping("/search")
    public PageResult<Tsn> search(@RequestParam("page") Integer page,
                                  @RequestParam("pageSize") Integer pageSize,
                                  @RequestBody(required = false) TsnVo tbspecVo){
        System.out.println(tbspecVo);
        return tbService.search(page,pageSize,tbspecVo);
    }
    @PostMapping("/save")
    public R save(@RequestBody Tsn user){
        return tbService.save(user) ? R.ok().message("添加成功！") : R.error().message("添加失败！");
    }
}
